02. User Signup
User Signup
Question:
Start Quiz:

INSTRUCTOR NOTE:
In order to be graded correctly for this homework, there are a few things to
keep in mind. We'll be grading your web app by posting to your form and then
checking the HTTP Response we receive. There are a few main issues you need to
keep in mind in order for this to work:
- The form elements where the user inputs their username, password, password
again, and email address must be named "username", "password",
"verify", and "email", respectively. - The form method must be POST, not GET.
- Upon invalid user input, your web app should re-render the form for the user.
- Upon valid user input, your web app should redirect to a welcome
page for the user.
- This page must include both "Welcome" and the user's username.
- You must enter the full url into the supplied textbox above, including the
path. For example, our example app is running at
http://udacity-cs253.appspot.com/unit2/signup, but if we instead only entered
http://udacity-cs253.appspot.com/ then the grading script would not work.
Regular Expressions
A regular expression is a handy tool for matching text to a pattern. The regular expressions that we're using to validate you input are as follows:
- Username: "^[a-zA-Z0-9_-]{3,20}$"
- Password: "^.{3,20}$"
- Email: "^[\S]+@[\S]+\.[\S]+$"
Example code for validating a username is as follows:
import re USER_RE = re.compile(r"^[a-zA-Z0-9_-]{3,20}$") def valid_username(username): return USER_RE.match(username)
More information on using regular expressions in Python can be found here
NOTE: When you go off to make real applications that require form validation, remember that using regex to check an email address is not quite as simple as we make it seem here. See this Stack Overflow question for more on email validation.